<?php

namespace App\Http\Requests\Project;

use App\Rules\Mobile;
use Illuminate\Foundation\Http\FormRequest;

class ContractRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $id =request()->input('id');
       return [
            'project_name' => 'required|unique:pm_contracts,project_name,' . $id,
            'project_type_id' => 'required',
            'scale' => 'required',
            'sign_company_id' => 'required',
            'signed_at' => 'required|date_format:"Y-m-d"',
            'required_finish_at' => 'required|date_format:"Y-m-d"',
            'contract_amount' => 'required|numeric',
            'pay_times' => 'required|integer',
            'payment_agreement' => 'required',
            'owner_unit' => 'required',
            'owner_contact' => 'required',
            'owner_mobile' => 'required',
            'province_id' => 'required',
            'city_id' => 'required',
            'area_id' => 'required',
            'detail_address' => 'required',
            'cooperation_mode' => 'required',
            'source' => 'required',
         //   'professional_director_uid' => 'required',
            'contract_director_uid' => 'required',
            'inner_docking_uid' => 'required',
        ];
    }

    public function messages()
    {
        return [
            'project_name.required' => '请填写项目名称！',
            'project_name.unique' => '已有其他人提交过这个项目！',
            'project_type_id.required' => '请选择项目类型！',
            'scale.required' => '请填写项目规模！',
            'sign_company_id.required' => '请选择签订公司！',
            'signed_at.required' => '请填写签订时间！',
            'required_finish_at.required' => '请填写要求完成时间！',
            'contract_amount.required' => '请填写合同金额！',
            'contract_amount.numeric' => '请填写合同金额必须位数字！',
            'pay_times.required' => '请填写付款次数！',
            'pay_times.integer' => '请填写付款次数必须是数字！',
            'payment_agreement.required' => '请填写条件！',
            'owner_unit.required' => '请填写业主单位！',
            'owner_contact.required' => '请填写业联系人！',
            'owner_mobile.required' => '请填写业联系人电话！',
            'province_id.required' => '请选择项目所在地区！',
            'city_id.required' => '请选择项目所在地区！',
            'area_id.required' => '请选择项目所在地区！',
            'detail_address.required' => '请填写项目详细地址！',
            'cooperation_mode.required' => '请选择合作方式！',
            'source.required' => '请填写项目来源！',
            'professional_director_uid.required' => '请选择专业负责人！',
            'contract_director_uid.required' => '请选择合同负责人！',
            'inner_docking_uid.required' => '请选择公司内部对接人！',
        ];
    }

}
